<!doctype html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>图片上传组件</title>
	<link rel="stylesheet" href="<?= APP_ROOT ?>static/view/manage/layui/css/layui.css">
	<link href="<?= APP_ROOT ?>static/view/manage/css/lib-app.css" rel="stylesheet" type="text/css" />
</head>
<body>
	<form enctype="multipart/form-data" method="post" name="upform">
		<!-- <input type="text" id="selectFile" disabled>
		<span class="input-file">浏览...<input type="file" id="filename" name="filename[]" multiple /></span>
		<input type="submit" id="btnSubmit" value="上传">支持类型：jpg, png, gif, bmp -->

		<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" id="upload-size">
			<i class="layui-icon"></i>浏览文件
		</button>
		<button type="submit" class="layui-btn layui-btn-sm" id="test-upload-size">上传</button>
		<input class="layui-upload-file" type="file" id="filename" accept="" name="filename[]" multiple>
		<div class="layui-inline layui-word-aux" id="tips"></div>
	</form>

	<script type="text/javascript">
		function onBack(name, val) {
			var _vals = val.split(",");
			var _img = '';
			for(var i = 0; i < _vals.length; i++) {
				_img += '<li><a onClick="remove_input(this)">移除×</a><img src = "/static/'+ _vals[i] +'" /></li>';
			}
			
			var p_html = parent.document.getElementById('s_'+name)
			var p_val = parent.document.getElementById(name);
			
			if(p_val.value) {
				var _total_img = p_html.innerHTML + _img;
				var _total_val = p_val.value +','+ val;
				p_html.innerHTML = _total_img;
				p_val.value = _total_val;
			}
			else {
				p_html.innerHTML = _img;
				p_val.value = val;
			}	
		}

		document.getElementById('upload-size').onclick = function() {
			document.getElementById('filename').click();
		}
	
		document.getElementById('filename').onchange = function(e) {
			document.getElementById('tips').innerHTML = e.target.files.length + '个文件等待上传';
		}
	</script>
</body>
</html>
